package com.reyco1.medusa.util
{
	public class ClassUtil
	{
		import flash.display.Bitmap;
		import flash.display.MovieClip;
		import flash.display.Sprite;
		import flash.media.Sound;
		import flash.text.Font;
		import flash.utils.describeType;
		import flash.utils.getDefinitionByName;
		import flash.utils.getQualifiedClassName;
		
		public static function className(cliassIdentifier:Object):String
		{
			var strName:String = getQualifiedClassName(cliassIdentifier);
			strName = strName.slice(strName.lastIndexOf(":") + 1, strName.length);
			return strName;
		}
		
		public static function displayClassName(cliassIdentifier:Object):String
		{
			return "[" + ClassUtil.className(cliassIdentifier) + "]";
		}
		
		public static function classReference(classIdentifier:String):Class
		{
			return flash.utils.getDefinitionByName(classIdentifier) as Class;
		}
		
		public static function getSprite(classIdentifier:String):Sprite
		{
			var instance:Class = ClassUtil.classReference(classIdentifier);
			var sprite:Sprite = new instance() as Sprite;
			return sprite;
		}
		
		public static function getMovieClip(classIdentifier:String):MovieClip
		{
			var instance:Class = ClassUtil.classReference(classIdentifier);
			var movieclip:MovieClip = new instance() as MovieClip;
			return movieclip;
		}
		
		public static function getSound(classIdentifier:String):Sound
		{
			var instance:Class = ClassUtil.classReference(classIdentifier);
			var sound:Sound = new instance() as Sound;
			return sound;
		}
		
		public static function getBitmap(classIdentifier:String):Bitmap
		{
			var instance:Class = ClassUtil.classReference(classIdentifier);
			var bitmap:Bitmap = new instance() as Bitmap;
			return bitmap;
		}
		
		public static function getFont(classIdentifier:String):Font
		{
			var instance:Class = ClassUtil.classReference(classIdentifier);
			var font:Font = new instance() as Font;
			Font.registerFont(instance);
			return font;
		}
	}
}